package cn.edu.scau.cmi.xuxingao.comprehensiveExperiment;


import cn.edu.scau.cmi.xuxingao.client.AdapterClient;
import cn.edu.scau.cmi.xuxingao.client.CompositeClient;
import cn.edu.scau.cmi.xuxingao.client.FactoryClient;
import cn.edu.scau.cmi.xuxingao.client.InterProgrammingClient;
import cn.edu.scau.cmi.xuxingao.client.SingletonClient;
import cn.edu.scau.cmi.xuxingao.hibernate.client.HibernateClient;
import cn.edu.scau.cmi.xuxingao.spring.client.ApplicationContextClient;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Client extends Application{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		launch(args);
	}
	
	Button btn1 = new Button("实验一：接口编程");
	Button btn2 = new Button("实验二：单例模式与多例模式");
	Button btn3 = new Button("实验三：工厂模式");
	Button btn4 = new Button("实验四：适配器模式");
	Button btn5 = new Button("实验五：组合模式");
	Button btn6 = new Button("实验六：ORM模式与Hibernate框架");
	Button btn7 = new Button("实验七：基于IOC、DI的Spring框架");
	@Override
	public void start(Stage stage) throws Exception {
		// TODO Auto-generated method stub
		btn1.setOnAction((ActionEvent e) -> {
			InterProgrammingClient i = new InterProgrammingClient();
			String[] args = null;
			i.main(args);
		});
		
		btn2.setOnAction((ActionEvent e) -> {
			Stage s1 = new Stage();
			s1.setTitle("单例模式与多例模式");
			new SingletonClient().start(s1);

		});
		
		btn3.setOnAction((ActionEvent e) -> {
			Stage s1 = new Stage();
			s1.setTitle("工厂模式");
			try {
				new FactoryClient().start(s1);
			} catch (Exception e8) {
				// TODO Auto-generated catch block
				e8.printStackTrace();
			}
		});
		
		btn4.setOnAction((ActionEvent e) -> {
			Stage s1 = new Stage();
			s1.setTitle("适配器模式");
			try {
				new AdapterClient().start(s1);
			} catch (Exception e8) {
				// TODO Auto-generated catch block
				e8.printStackTrace();
			}
		});
		
		btn5.setOnAction((ActionEvent e) -> {
			Stage s1 = new Stage();
			s1.setTitle("组合模式");
			try {
				new CompositeClient().start(s1);
			} catch (Exception e8) {
				// TODO Auto-generated catch block
				e8.printStackTrace();
			}
		});
		
		btn6.setOnAction((ActionEvent e) -> {
			Stage s1 = new Stage();
			s1.setTitle("Hibernate框架");
			try {
				HibernateClient c = new HibernateClient();
				String[] args = null;
				c.main(args);
			} catch (Exception e8) {
				// TODO Auto-generated catch block
				//e8.printStackTrace();
			}
		});
		
		btn7.setOnAction((ActionEvent e) -> {
			Stage s1 = new Stage();
			s1.setTitle("Spring集成Hibernate框架");
			try {
				ApplicationContextClient h=new ApplicationContextClient();
				String[] args = null;
				h.main(args);
			} catch (Exception e8) {
				// TODO Auto-generated catch block
				e8.printStackTrace();
			}
		});
		
		FlowPane  root = new FlowPane();
		VBox v = new VBox();
		VBox vv=new VBox();
		
		HBox h=new HBox();
		Label l = new Label("徐星澳-201727010625");
		Label l0 = new Label("");
		h.getChildren().addAll(l);
		vv.getChildren().addAll(h,l0);
		
		HBox h1 = new HBox();
		Label l1 = new Label("无图形界面请看Console");
		h1.getChildren().addAll(btn1, l1);
		
		HBox h2 = new HBox();
		Label l2 = new Label("");
		h2.getChildren().addAll(btn2, l2);
		
		HBox h3 = new HBox();
		Label l3 = new Label("");
		h3.getChildren().addAll(btn3, l3);
		
		HBox h4 = new HBox();
		Label l4 = new Label("");
		h4.getChildren().addAll(btn4, l4);
		
		HBox h5 = new HBox();
		Label l5 = new Label("");
		h5.getChildren().addAll(btn5, l5);
		
		HBox h6 = new HBox();
		Label l6 = new Label("无图形界面请看Console");
		h6.getChildren().addAll(btn6, l6);
		
		HBox h7 = new HBox();
		Label l7 = new Label("无图形界面请看Console");
		h7.getChildren().addAll(btn7, l7);
		
		v.getChildren().addAll(vv,h1, h2, h3, h4, h5, h6, h7);
		root.getChildren().addAll(v);
		Scene scene = new Scene(root, 600, 400);
	    stage.setScene(scene);
	    stage.setTitle("综合性实验");
	    stage.show();
	}
	
}